<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/1/31
 * Time: 16:48
 */

namespace app\index\controller;




class SendSms extends Base
{
    /**
     * 发送登录短信
     */
    public function send()
    {
        $tel = $this->request->post('phone_num');
//        验证电话号码格式
        if (!preg_match("/^1[34578]\d{9}$/", $tel)) {
            return $this->ajaxError('电话格式不正确');
        }
        //组装task任务数据
        $taskData = $this->taskData('smsTask',['tel'=>$tel]);
        // 创建task任务 并进行投递
        $_POST['swoole_http_obj']->task($taskData);
        return $this->ajaxSuccess('验证码发送成功');
    }
}